import {
  View,
  Text,
  Button,
  StyleSheet,
  ActivityIndicator,
  Image,
  ImageBackground,
  KeyboardAvoidingView,
  Platform,
  TextInput,
  Modal,
  Pressable,
} from 'react-native';
import React, {useState} from 'react';
import xxmLogo from './image/xxmLogo.png';

export default function Test() {
  const [visible, setVisible] = useState(false);
  function handlePress() {
    fetch(
      'http://10.62.64.15/app-sys/logoResource/getLogoUrl?languageType=zh-CN',
    )
      .then(response => response.json())
      .then(data => {
        console.log('data', data);
      });
  }
  function handleModal() {
    setVisible(true);
  }
  function handleQuestClose() {
    console.log(13211);
    setVisible(false);
  }
  function handleClose() {
    setVisible(false);
  }

  function fn() {
    console.log(1111111);
  }
  return (
    <KeyboardAvoidingView
      behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
      style={styles.container}>
      <View style={styles.box}>
        {/* <Image style={styles.img} source={require('./image/xxmLogo.png')} /> */}
        <ImageBackground style={styles.img} source={xxmLogo}>
          <Text>hello</Text>
        </ImageBackground>
        <TextInput placeholder="请输入" />
        {/* <Image
        style={styles.img}
        source={{
          uri: 'http://gips3.baidu.com/it/u=1821127123,1149655687&fm=3028&app=3028&f=JPEG&fmt=auto?w=720&h=1280',
        }}
      /> */}
        {/* <ActivityIndicator size="large" color={'red'} /> */}
        <Text style={styles.text}>Test</Text>
        <Button onPress={handlePress} title="点击请求" disabled={false} />
        <Button onPress={handleModal} title="点击Modal" disabled={false} />
        <Modal
          visible={visible}
          onRequestClose={handleQuestClose}
          animationType="fade">
          <View>
            <Text>12131</Text>
            <Button onPress={handleClose} title="关闭" />
          </View>
        </Modal>
        <Pressable
          onPressIn={fn}
          style={({pressed}) => [{opacity: pressed ? 0.5 : 1}]}>
          {({pressed}) => <Text>{pressed ? 'Pressed!' : 'Press Me'}</Text>}
        </Pressable>
      </View>
    </KeyboardAvoidingView>
  );
}

const styles = StyleSheet.create({
  container: {
    height: '100%',
    backgroundColor: '#fff',
  },
  box: {
    height: '100%',
    justifyContent: 'space-around',
  },
  text: {
    color: 'red',
    fontSize: 20,
  },
  img: {
    width: 200,
    height: 200,
  },
});
